//Ta Duc Viet - 11020397
//5/3/12
//Tinh luy thua x^n
#include <iostream>
using namespace std;
int main()
{
   float x, n, LuyThua;
   cout << "Tinh x^n:" << endl;
   cout << "x = ";
   cin >> x;
   cout << "n = ";
   cin >> n;
   float x3 = x*x*x;
   if (n == 0) cout << x << "^" << n << " = 1" << endl;
   else
   {
       int i;
	   LuyThua = x;
	   for (i = 4; i <= n; i = i + 3)
	   {
		  LuyThua = LuyThua*x3;
		}
		if ( i - 3 == n - 1) LuyThua = LuyThua*x;
		if ( i - 3 == n - 2) LuyThua = LuyThua*x*x;
   cout << x << "^" << n << " = " << LuyThua << endl;
   }
   system("pause");
   return 0;
}
